package emd24.telstudyresources;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

public class BankHeader implements Parcelable {
	private String name;
	private String url;
	private int numQuestions;
	private int defaultTime;

	public BankHeader(String name, String url, int numQuestions,
			int defaultTime) {
		this.name = name;
		this.url = url;
		this.numQuestions = numQuestions;
		this.defaultTime = defaultTime;
	}
	/**
	 * Creates a BankHeader from a JSONObject
	 * 
	 * @param js JSONObject to create bank header from
	 * @throws JSONException
	 */
	public BankHeader(JSONObject js) throws JSONException{
		this.name = js.getString("Name");
		this.url = js.getString("URL");
		this.numQuestions = js.getInt("NumQuestions");
		this.defaultTime = js.getInt("RecTime");
	}
	public BankHeader(Parcel in) {
		this.name = in.readString();
		this.url = in.readString();
		this.numQuestions = in.readInt();
		this.defaultTime = in.readInt();
		
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public int getNumQuestions() {
		return numQuestions;
	}
	public void setNumQuestions(int numQuestions) {
		this.numQuestions = numQuestions;
	}
	/**
	 * Gets the default time (in minutes)
	 * 
	 * @return default number of minutes
	 */
	public int getDefaultTime() {
		return defaultTime;
	}
	/**
	 * Sets the default time (in mimutes)
	 * 
	 * @param defaultTime recommended number of minutes for quiz
	 */
	public void setDefaultTime(int defaultTime) {
		this.defaultTime = defaultTime;
	}
	public static final Parcelable.Creator<BankHeader> CREATOR
	= new Parcelable.Creator<BankHeader>() {
		public BankHeader createFromParcel(Parcel in) {
			return new BankHeader(in);
		}

		public BankHeader[] newArray(int size) {
			return new BankHeader[size];
		}
	};
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.name);
		dest.writeString(this.url);
		dest.writeInt(this.numQuestions);
		dest.writeInt(this.defaultTime);

	}

}
